<?php
/**
 * TaskUpdate
 *-------------------------
 *
 * Deal with menu display, selected status. Top menu - sub menu 
 *
 * PHP versions 5
 *
 * LICENSE: This source file is from Smarter Ver4.0, which is a comprehensive shopping engine
 * that helps consumers to make smarter buying decisions online. We empower consumers to compare
 * the attributes of over one million products in the computer and consumer electronics categories
 * and to read user product reviews in order to make informed purchase decisions. Consumers can then
 * research the latest promotional and pricing information on products listed at a wide selection of
 * online merchants, and read user reviews on those merchants.
 * The copyrights is reserved by http://www.mezimedia.com.
 * Copyright (c) 2005, Mezimedia. All rights reserved.
 *
 * @author     jack.xie <jack_xie@mezimedia.com>
 * @copyright  (C) 2004-2008 Mezimedia.com
 * @license    http://www.mezimedia.com  PHP License 5.2
 * @version    CVS: $Id: UserController.php
 * @link       http://pms.mezimedia.com/
 * @deprecated File deprecated in Release 1.0
 */

class TaskUpdate extends Zend_Db_Table
{	
	/*
	$data		//an associative array of columns to change and new values to assign to these columns
	$where		//a WHERE clause
	*/

	public $_db = null;
	public $_filter_list =array();
	public $_raw_task_list = array();
	public $_sup_task_list = array();

	
	public function __construct () {
		$this->_db = Zend_Registry :: get('db_adapter');
		$this->_name = 'tt_st_task_update';
		$this->_primary = 'id';
		parent::_setup();
	}

	public function getCols () {
		return $this->_cols;
	}
	
	public function find($where) {
		$select = $this->_db->select();
		$select->from($this->_name, '*');
		$select->join('tt_user', 'tt_st_task_update.user_id = tt_user.id', 'tt_user.name as username');
		$select->where($where);
		$sql = $select->__toString();
		return $this->_db->fetchAll($sql);
	}
	
	public function insert(array $data, $task_id) {
		$update['task_id'] = $task_id;
		$user = Zend_Auth::getInstance()->getIdentity();
		$update['user_id'] = $user['userId'];
		$update['content'] = $data['task_update'];
		$update['update_time'] = date('Y-m-d H:i:s');
		parent::insert($update);
	}
	/**
	 * custom update
	 *
	 * @param array $data
	 * @param integer $id
	 * @return mixed
	 * @throws Zend_Db_Exception
	 */
    public function update (array $data, $id)
    {
        $where = $this->_db->quoteInto('id = ?', $id);
        return parent::update($data, $where);
    }
}
?>